package com.taldh;

import org.junit.Assert;
import org.junit.Test;

public class JudgeSquareSum {

    @Test
    public void judgeSquareSumTest() {
        Assert.assertTrue(judgeSquareSum(5));
        Assert.assertTrue(judgeSquareSum(4));
    }

    public boolean judgeSquareSum(int c) {
        int i = 0;
        int j = c - 1;
        while (i <= j) {
            int var = i * i + j * j;
            if (var == c) {
                return true;
            } else if (var < c) {
                i ++;
            } else {
                j --;
            }
        }
        return false;
    }

}
